<?php

/* 会员 member */
class FactorytypeModel extends BaseModel
{
    var $table  = 'factory_type';
    var $prikey = 'type_id';
    var $_name  = 'ft';
	
    var $_relation = array(
		'has_factory' => array(
            'model'         => 'factory',
            'type'          => HAS_MANY,
            'foreign_key'   => 'type_id',
        ),
	);

    /*
     * 判断名称是否唯一
     */
    function unique($type_name, $type_id = 0)
    {
        $conditions = "type_name = '" . $type_name . "'";
        $type_id && $conditions .= " AND type_id <> '" . $type_id . "'";
        return count($this->find(array('conditions' => $conditions))) == 0;
    }
}

?>